package com.googlecode.data.markers
{
	import com.googlecode.data.IValueObject;
	
	import org.papervision3d.core.math.Number3D;
	
	public class KeyframeVO extends BaseMarker
	{	
		
		public static const TYPE:String = "KeyFrame";
		
		public var position:Number3D = new Number3D(0, 0, 0);
		
		public var isDraggable:Boolean = true;
		
		public var time:Number = 0;
		//
		
		override public function clone(src:* = null):IValueObject
		{
			var clone:IValueObject = super.clone(new KeyframeVO());
			
			(clone as KeyframeVO).position = this.position;
			(clone as KeyframeVO).isDraggable = this.isDraggable;
			(clone as KeyframeVO).time = this.time;
			
			return clone;
		}
		
		override public function toXML(src:XML = null):XML
		{
			var xml:XML = super.toXML(new XML(<{TYPE} id={this.id}></{TYPE}>));
			
			xml.appendChild(<position>{this.position.x + " " + this.position.y + " " + this.position.z}</position>);
			xml.appendChild(<isDraggable>{this.isDraggable}</isDraggable>);
			xml.appendChild(<time>{this.time}</time>);

			return xml;
		}
		
		override public function fromXML(src:XML):void
		{
			super.fromXML(src);
			
			this.position.x = int((src.position as String).split(" ")[0]);
			this.position.y = int((src.position as String).split(" ")[1]);
			this.position.z = int((src.position as String).split(" ")[2]);
			
			this.isDraggable = src.isDraggable;
			this.time = src.time;
	
		}

	}
}